XOR block

Short summary

Name

XOR

→POU type

→function

Category

IEC-block, Bitstring

Conform to →IEC-standard

(tick) no restrictions

Graphical interface

Available since

  • version 1.0.0 (for Neuron Power Engineer) – initial variant

  • version 3.2.5 (for library Standard) – internal matters refactored in order to prevent warnings when compiling

Functionality

The block returns the result of a bitwise EXCLUSIVE-OR operation of all values connected to the inputs.

According to the table 31 of the →IEC-standard, the behavior of the statement XOR(a,b,c,d) corresponds to the behavior of the statement a XOR b XOR c XOR d. These statements are processed from left to right according to the priority of the operators in ST. Thus, first result = a XOR b is evaluated, then result2 = result XOR c  and then endResult = result2 XOR d.

Inputs, return value

 

Identifier

→Data type

Description

Inputs:

IN1

 BOOLBYTEWORDDWORD or LWORD
(corresponds to →generic data type ANY_BIT

1st value

IN2

 BOOLBYTEWORDDWORD or LWORD
(corresponds to →generic data type ANY_BIT

2nd value

... (extensible until)

IN16

 BOOLBYTEWORDDWORD or LWORD
(corresponds to →generic data type ANY_BIT

16th value

Return value:

 BOOLBYTEWORDDWORD or LWORD
(corresponds to →generic data type ANY_BIT

 

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
    VAR
        result1, result2, result3, result4 : BOOL;
    END_VAR
    result1 := XOR(IN1 := FALSE, IN2 := FALSE);       (* The variable 'result1' evaluates to 'FALSE'. *)
    result2 := XOR(IN1 := FALSE, IN2 := TRUE );       (* The variable 'result2' evaluates to 'TRUE'.  *)
    result3 := XOR(IN1 := TRUE,  IN2 := FALSE);       (* The variable 'result3' evaluates to 'TRUE'.  *)
    result4 := XOR(IN1 := TRUE,  IN2 := TRUE );       (* The variable 'result4' evaluates to 'FALSE'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.